/*
 * Main.fx
 *
 * Created on 01.12.2009, 16:52:40
 */

package javafx179labs.usman.lab4;;

import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.scene.transform.Rotate;
import javafx.scene.image.Image;
import javafx.animation.Timeline;
import javafx.animation.KeyFrame;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.scene.media.MediaView;


/**
 * @author Alex
 */
var myPlayer = MediaPlayer {
    autoPlay: false
    media: Media { source: "{__DIR__}kill.mp3"}
}

var mediaView: MediaView = MediaView {
    mediaPlayer: myPlayer
}


var r: Number = 0;
var ob:ImageView= ImageView{
x:0
y:0
fitWidth:158
fitHeight:51
  image: Image {
  url: "{__DIR__}ob.png"
                }
                }
var park :ImageView= ImageView{
fitWidth:700
fitHeight:450
  image: Image {
  url: "{__DIR__}park.jpg"  }
  }
var kenny:ImageView= ImageView{
x:0
y:270
fitWidth:75
fitHeight:150
  image: Image {
  url: "{__DIR__}12.png"
                }
                


                             }
var bryan:ImageView= ImageView{
x:500
y:250
fitWidth:75
fitHeight:150
  image: Image {
  url: "{__DIR__}22.png"
                }
           onMouseClicked: function( e: MouseEvent ):Void {
                           insert pist into animated.scene.content;
time1.play();
                }
           }
var pist :ImageView= ImageView{
transforms:Rotate { pivotX : bind pist.x, pivotY : bind pist.y, angle: bind r }
x:525
y:325
fitWidth: 50
fitHeight:75
  image: Image {
  url: "{__DIR__}pist.png"  }
  onMouseClicked: function( e: MouseEvent ):Void {
                           insert pat into animated.scene.content;
                           

                           time2.play();
                }
  }
var pat :ImageView= ImageView{
x:400
y:325
fitWidth:50
fitHeight:10
  image: Image {
  url: "{__DIR__}pat.png"  }

  }
  
  var blood :ImageView= ImageView{
fitWidth:500
fitHeight:750
  image: Image {
  url: "{__DIR__}blood.png"  }
  }



var time1:Timeline=Timeline {
    repeatCount: 1;
    keyFrames : [
            at (5s) {kenny.x=>200;}
            at (2s) {kenny.y=>250;}
            at (5s) {r=>90;}
            
            ]

}
var fonmuvi:Timeline=Timeline {
    repeatCount:3;
    keyFrames : [
            at (120s) {ob.x=>500;}
            at (200s) {ob.y=>-50;}
            

            ]}
            fonmuvi.play();
            
var time2:Timeline = Timeline {
     repeatCount: 1
     keyFrames : [
     at(4s) {pat.x=>200;}
     KeyFrame {
          time : 3s
        action: function()
  {   insert blood into animated.scene.content;}}
  KeyFrame {
          time : 3s
        action: function()
  { delete ob from animated.scene.content;}
  }

  KeyFrame {
          time : 3s
        action: function()
  {    myPlayer.play();}
  }
     ]
}

var animated:Stage=Stage {


    title: "Application title"
    width: 700
    height: 450
    scene: Scene {
        content: [ 
         park,kenny,bryan,ob
         
       
            
        ]
    }
}